package bit.mybatisdemo.demos.Controller;

import bit.mybatisdemo.demos.mapper.UserInfoMapper;
import bit.mybatisdemo.demos.model.UserInfo;
import bit.mybatisdemo.demos.service.UserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

@RestController
@RequestMapping("/user")
public class UserController {
    //@Autowired
   // private UserService userInfo;
    @Autowired
    private UserService userService;

    @RequestMapping("/getAllUser")
    public List<UserInfo> getUserInfo() {
        return userService.getAllUser();
    }

    @RequestMapping("/getByUserID")
    public UserInfo getUserInfoByUserID(int id) {
        return userService.getUserById(id);
    }

    @RequestMapping("/login")
    public boolean login(String username, String password){
        UserInfo userInfo=userService.queryUser(username,password);
        return userInfo!=null;
    }
}
